home *** CD-ROM | disk | FTP | other *** search
/ One Click 14 / OneClick14.iso / Ferramentas / Convert XLS to Pdf / xls2pdf_setup.exe / {app} / lib / gs_ciddc.ps < prev    next >
Encoding:
Text File  |  2002-02-22  |  7.7 KB  |  209 lines

  1. %    Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_ciddc.ps,v 1.7 2002/02/21 23:14:05 igor Exp $
  14. % Define Decoding and CIDDecoding resource categories and related procsets.
  15.  
  16. languagelevel 2 .setlanguagelevel
  17. currentglobal true setglobal
  18.  
  19. %----------------ParseDecoding procset----------------------------
  20.  
  21. /ParseDecoding <<
  22.  
  23. /Parse    % <resource_name> <num_tokens> Parse -
  24. { dict begin                                  % /ResName
  25.   0                                           % /ResName nCode
  26.   { currentfile token not {
  27.       exit
  28.     } if                                      % /ResName nCode token
  29.     dup type /integertype eq {                % /ResName nCode
  30.        exch pop
  31.     } {
  32.       1 index def                             % /ResName nCode
  33.     } ifelse
  34.   } loop                                      % /ResName nCode
  35.   pop                                         % /ResName
  36.   currentdict end /Decoding                   % /ResName <<inst>> /Decoding
  37.   defineresource pop
  38. } bind
  39.  
  40. >> /ProcSet defineresource pop
  41.  
  42. %----------------Decoding category----------------------------
  43.  
  44. /Generic /Category findresource dup length dict copy
  45. dup /InstanceType /dicttype put
  46. /Decoding exch /Category defineresource pop
  47.  
  48. %----------------ParseCMap_Inverse procset----------------------------
  49.  
  50. /ParseCMap_Inverse <<
  51.   /findresource { pop } bind
  52.   /defineresource { pop pop } bind
  53.   /dict {}
  54.   /def { pop pop } bind
  55.   /dup null
  56.   /begin { pop } bind
  57.   /end {}
  58.   /currentdict null
  59.   /CMapName null
  60.   /usecmap { pop } bind
  61.   /begincmap {}
  62.   /endcmap {}
  63.   /begincodespacerange { pop mark } bind
  64.   /endcodespacerange { cleartomark } bind
  65.   /beginnotdefrange { pop mark } bind
  66.   /endnotdefrange { cleartomark } bind
  67.   /beginbfchar { pop mark } bind
  68.   /endbfchar { pop mark } bind
  69.   /beginbfrange { begincidrange }
  70.   /endbfrange { endcidrange }
  71.   /begincidchar { beginbfchar }
  72.   /endcidchar { endbfchar }
  73.   /begincidrange { pop mark } bind
  74.   /endcidrange  { cleartomark } bind
  75. >>  % Just keep it on stack for a while.
  76.  
  77. % Now we define another dict for local binding, than merge it with the previous one :
  78. dup length 5 add dict begin
  79.  
  80.   /.Ranges 40 dict def % Key = CID/256, value = array of 256 integer codes.
  81.   //.Ranges /CIDCount 0 put
  82.  
  83.   /.StringToInt     % <string> .StringToInt <integer>
  84.   { 0 exch { exch 8 bitshift add } forall
  85.   } bind def
  86.  
  87.   /.SetCouple    % <I> <b> .SetCouple -
  88.   { exch                                    % b I
  89.     dup 256 idiv                            % b I I0
  90.     dup //.Ranges exch known not {
  91.       dup //.Ranges exch 256 array put
  92.     } if                                    % b I I0
  93.     //.Ranges exch get                      % b I [Range]
  94.     exch 256 mod                            % b [Range] I1
  95.     3 2 roll put                            %
  96.   } bind def
  97.  
  98.   /endcidrange
  99.   { % Writes the inversed CMap to .Ranges
  100.     counttomark 3 idiv {                    % (b) (e) I
  101.       exch .StringToInt                     % (b) I e
  102.       3 2 roll .StringToInt                 % I e b
  103.       % Note : this code does't handle multidimentional CID ranges.
  104.       % fixme : optimize below.
  105.       dup 3 2 roll exch sub 1 add           % I b d
  106.       { 2 copy //.SetCouple exec            % I b
  107.         1 add exch 1 add exch
  108.       } repeat                              % I b
  109.       pop                                   % I
  110.       dup //.Ranges /CIDCount get gt {      % I
  111.         dup //.Ranges exch /CIDCount exch put
  112.       } if                                  % I
  113.       pop
  114.     } repeat
  115.     pop % mark
  116.   } bind def
  117.  
  118.   /.PurgeDict   % <dict> .PurgeDict -
  119.   { { true
  120.       1 index { pop exch pop false exit
  121.       } forall
  122.       { exit
  123.       } if
  124.       1 index exch undef
  125.     } loop
  126.     pop
  127.   } bind def
  128.  
  129.   /.GetCIDDecoding         % - .GetCIDDEcoding <dict>
  130.   { //.Ranges dup length dict copy
  131.     //.Ranges //.PurgeDict exec
  132.     //.Ranges /CIDCount 0 put
  133.   } bind def
  134.  
  135. currentdict end
  136. exch copy % Merge the dicts - see above.
  137. /ProcSet defineresource pop
  138.  
  139. %----------------CIDDecoding category----------------------------
  140. % Note that we put all instances in global memory - see FindResource.
  141.  
  142. /Generic /Category findresource dup length dict copy
  143. begin
  144.   /Category /CIDDecoding def
  145.   /InstanceType /dicttype def
  146.  
  147.   /.CMapChooser <<
  148.     % This lists CMaps to inverse and unite for creating a CIDDecoding.
  149.     % Choose by FAPIcidfmap.Registry concatenated with TrueType encoding ID.
  150.     % Font renderer must provide the glyph substitution internally.
  151.  
  152.     /CNS1.Big5       [ /ETen-B5-H /ETen-B5-V ]
  153.     /CNS1.Unicode    [ /UniCNS-UCS2-H /UniCNS-UCS2-V]
  154.     /GB1.GB2312      [ /GBK-EUC-H /GBK-EUC-V ]
  155.     /GB1.Unicode     [ /UniGB-UCS2-H /UniGB-UCS2-V ]
  156.     /Japan1.ShiftJIS [ /90ms-RKSJ-H /90ms-RKSJ-V ]
  157.     /Japan1.Unicode  [ /UniJIS-UCS2-H  /UniJIS-UCS2-V]
  158.     /Japan2.ShiftJIS [ /90ms-RKSJ-H /90ms-RKSJ-V ]
  159.     /Japan2.Unicode  [ /UniHojo-UCS2-H ]
  160.     /Korea1.Johab    [ /KSC-Johab-V /KSC-Johab-H ]
  161.     /Korea1.Wansung  [ /KSCms-UHC-V /KSCms-UHC-H ]
  162.     /Korea1.Unicode  [ /UniKS-UCS2-H /UniKS-UCS2-V ]
  163.   >> def
  164.  
  165.   /.MakeInstance    % <name> .MakeInstance <inst>
  166.   { dup                                              % /Name /Name
  167.     //.CMapChooser exch .knownget not {
  168.       (Can't build /) print =string cvs print ( /CIDDecoding. ) =
  169.       /findresource cvx /undefinedresource signalerror
  170.     } if                                             % /Name [CMaps]
  171.     exch pop                                         % [CMaps]
  172.     /CMap /Category findresource                     % [CMaps] <CMapCategory>
  173.     /ParseCMap_Inverse /ProcSet findresource         % [CMaps] <CMapCategory> <PCI>
  174.     3 2 roll {                                       % <CMapCategory> <PCI> /CMapName
  175.       3 2 roll begin                                 % <PCI> /CMapName
  176.       dup =string ResourceFileName                   % <PCI> /CMapName (path)
  177.       currentdict end exch                           % <PCI> /CMapName <CMapCategory> (path)
  178.       (r) { file } stopped {                         % <PCI> /CMapName <CMapCategory> (path)
  179.         pop                         
  180.         (Can't find ) print print ( building a CIDDecoding resource. ) =
  181.         /findresource cvx /undefinedresource signalerror
  182.       } if                                           % <PCI> /CMapName <CMapCategory> file
  183.       3 index begin
  184.       cvx exec                                       % <PCI> /CMapName <CMapCategory>
  185.       end
  186.       exch pop exch                                  % <CMapCategory> <PCI>
  187.     } forall
  188.     exch pop begin                                   %
  189.     .GetCIDDecoding
  190.     end
  191.   } bind def
  192.  
  193.   /FindResource      % <name> FindResource <dict>
  194.   { currentglobal exch                               % bGlobal /InstName
  195.     true setglobal
  196.     dup //.MakeInstance exec                         % bGlobal /InstName <Inst>
  197.     DefineResource                                   % bGlobal <Inst>
  198.     exch setglobal                                   % <Inst>
  199.   } bind def
  200.  
  201. currentdict end
  202. /CIDDecoding exch /Category defineresource pop
  203.  
  204. setglobal
  205. .setlanguagelevel
  206.